import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '../layout' //布局页

Vue.use(VueRouter)
//解决重复点击左侧菜单的报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


export const asyncRoutes = [
  {
    path: '/',
    redirect: '/index',
    component: Layout,
    meta: {
      title: "首页",
      icon: 'el-icon-s-home',
    },
    name: 'index',
    children: [
      {
        path: 'index',
        name: 'index',
        component: () => import('@/views/home.vue'),
        meta: {
          title: "首页",
        }
      },
    ]
  },
  {
    path: '/config',
    component: Layout,
    meta: {
      title: "配置管理",
      icon: 'el-icon-s-home',
    },
    name: 'config',
    children: [
      {
        path: 'config',
        name: 'config',
        component: () => import('@/views/config/index.vue'),
        meta: {
          title: "配置管理",
        }
      },
    ]
  },
  {
    path: '/business',
    component: Layout,
    meta: {
      title: "业务管理",
      icon: 'el-icon-s-custom',
    },
    name: 'business',
    children: [
      {
        path: 'jobSubsidy',
        name: 'jobSubsidy',
        component: () => import('@/views/jobSubsidy/index.vue'),
        meta: {
          title: "求职面试交通补贴管理",
        }
      },

      {
        path: 'youthHostel',
        name: 'youthHostel',
        component: () => import('@/views/youthHostel/index.vue'),
        meta: {
          title: "青年驿站管理",
        }
      },

      {
        path: 'affordableHousing',
        name: 'affordableHousing',
        component: () => import('@/views/affordableHousing/index.vue'),
        meta: {
          title: "保障性住房管理",
        }
      },

      {
        path: 'settlementSubsidy',
        name: 'settlementSubsidy',
        component: () => import('@/views/settlementSubsidy/index.vue'),
        meta: {
          title: "安家补贴管理",
        }
      },
      {
        path: 'employmentSubsidy',
        name: 'employmentSubsidy',
        component: () => import('@/views/employmentSubsidy/index.vue'),
        meta: {
          title: "就业补贴管理",
        }
      },
      {
        path: 'housingPurchaseSubsidy',
        name: 'housingPurchaseSubsidy',
        component: () => import('@/views/housingPurchaseSubsidy/index.vue'),
        meta: {
          title: "购房补贴管理",
        }
      },
      {
        path: 'startupSubsidy',
        name: 'startupSubsidy',
        component: () => import('@/views/startupSubsidy/index.vue'),
        meta: {
          title: "创业补贴管理",
        }
      },
      {
        path: 'youthStartupLoan',
        name: 'youthStartupLoan',
        component: () => import('@/views/youthStartupLoan/index.vue'),
        meta: {
          title: "青年创业贷款管理",
        }
      },
      {
        path: 'skillSubsidy',
        name: 'skillSubsidy',
        component: () => import('@/views/skillSubsidy/index.vue'),
        meta: {
          title: "技能补贴管理",
        }
      },
      {
        path: 'householdMove',
        name: 'householdMove',
        component: () => import('@/views/householdMove/index.vue'),
        meta: {
          title: "户籍迁移管理",
        }
      },
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/login'),
    meta: {
      title: "欢迎登录",
    },
    hidden: true //导航菜单忽略选项
  },
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes: asyncRoutes
})

export default router
